package com.aiju.app;

import android.content.Context;
import android.text.TextUtils;

import com.aiju.base.R;
import com.aiju.bean.Location;
import com.aiju.app.config.Environment;
import com.aiju.common.network.INetState;
import com.aiju.common.network.NetState;
import com.aiju.utils.AndrUtils;
import com.aiju.utils.Util;

/**
 * @version: V1.0
 * @author: 佐为
 * @date: 2016-12-08 11:05
 * @Description: 基础数据信息
 */
public class DataProvider implements IDataProvider {

    private Context mContext;

    private INetState mINetState;

    public DataProvider(Context context) {
        this.mContext = context.getApplicationContext();
        this.mINetState = new NetState(mContext);
    }

    @Override
    public Context getContext() {
        return mContext;
    }

    @Override
    public String getAppName() {
        return mContext.getString(R.string.app_name);
    }

    @Override
    public String getPackageName() {
        return TextUtils.isEmpty(mContext.getPackageName()) ? "" : mContext.getPackageName();
    }

    @Override
    public String getVersionName() {
        return AndrUtils.getVersionName(mContext);
    }

    @Override
    public String getImei() {
        return AndrUtils.getIMEI(mContext);
    }

    @Override
    public String getImsi() {
        return AndrUtils.getIMSI(mContext);
    }

    @Override
    public String getPhoneId() {
        return AndrUtils.getPhoneId(mContext);
    }

    @Override
    public String getModel() {
        return AndrUtils.getModel();
    }

    @Override
    public int getRamSize() {
        return AndrUtils.getRamSize(mContext);
    }

    @Override
    public INetState getNetState() {
        return mINetState;
    }

    @Override
    public int getNetType() {
        return mINetState.getNetType();
    }

    @Override
    public int getScreenWidth() {
        return AndrUtils.getWidthPixels(mContext);
    }

    @Override
    public int getScreenHeight() {
        return AndrUtils.getHeightPixels(mContext);
    }

    @Override
    public Location getLocation() {
        Double[] doubles = Util.getLocation(mContext);
        Location location = new Location(doubles[0], doubles[1]);
        return location;
    }

    @Override
    public Environment getAppEnvironment() {
        return Environment.DEVELOP;
    }

}
